From 061cd0f0e5c41335150e0d234d8ad0aff7b6da11 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 2 Feb 2017 12:48:59 +0100 Subject: [PATCH] x86emul: correct behavior for single iteration REP INS/OUTS The initial operation done on these paths may raise an exception (for ->read_io() that's possible only on the PV path, when the I/O port access check has been deferred). We have to suppress put_rep_prefix() updating rCX in that case. From an abstract perspective this also applies to RETRY being returned. Reported-by: Wei Liu Signed-off-by: Jan Beulich Reviewed-by: Wei Liu Tested-by: Wei Liu Reviewed-by: Andrew Cooper --- xen/arch/x86/x86_emulate/x86_emulate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index 21dd98cebc..dbda4b3b4a 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -3134,7 +3134,7 @@ x86_emulate( if ( nr_reps == 1 && ops->read_io && ops->write ) { rc = ops->read_io(port, dst.bytes, &dst.val, ctxt); - if ( rc == X86EMUL_OKAY ) + if ( rc != X86EMUL_UNHANDLEABLE ) nr_reps = 0; } if ( (nr_reps > 1 || rc == X86EMUL_UNHANDLEABLE) && ops->rep_ins ) @@ -3175,7 +3175,7 @@ x86_emulate( { rc = read_ulong(ea.mem.seg, ea.mem.off, &dst.val, dst.bytes, ctxt, ops); - if ( rc == X86EMUL_OKAY ) + if ( rc != X86EMUL_UNHANDLEABLE ) nr_reps = 0; } if ( (nr_reps > 1 || rc == X86EMUL_UNHANDLEABLE) && ops->rep_outs ) -- 2.30.2